#include "pch.h"
#include "selectcas.h"
#ifdef _WIN32_
#include <windows.h>
#endif
void* CompareAndSwap(void* addr, void* oldPtr, void* newPtr)
{
	void* pv = nullptr;
#ifdef _WIN32_
	pv = ::InterlockedCompareExchangePointer((void**)addr, newPtr, oldPtr);
#endif
	return pv;
}

int CompareAndSwap(volatile int* addr, int oldValue, int newValue)
{
	int i = 0;
#ifdef _WIN32_
	i = ::InterlockedCompareExchange((unsigned*)addr, newValue, oldValue);
#endif
	return i;
}